﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TD.Interface.Credits.Effects
{
    internal class Efx_Shaking : Effect
    {
        private readonly Random random = new Random();
        private const int MIN_SHIFT = 0x08;
        private const int MAX_SHIFT = 0x10;

        private int x;
        private int y;
        private Matrix matrix;

        public Efx_Shaking() :
            base(10)
        {
            x = MIN_SHIFT;
            y = MAX_SHIFT;
            matrix = Matrix.Identity;
        }

        protected override void TriggerEfx()
        {
            x = random.Next(MIN_SHIFT, MAX_SHIFT);
            y = random.Next(MIN_SHIFT, MAX_SHIFT);

            matrix = Matrix.CreateTranslation(x, y, 0f);

            base.TriggerEfx();
        }

        protected override Matrix[] ApplyMatrices()
        {
            return new Matrix[1] { matrix };
        }
    }
}
